package de.szut.ita13.rs.wave.entities;

import java.awt.Graphics;
import java.awt.Rectangle;

import de.szut.ita13.rs.wave.controller.Controller;
import de.szut.ita13.rs.wave.entites.trail.Trail;
import de.szut.ita13.rs.wave.entity.Entity;
import de.szut.ita13.rs.wave.entity.Type;
import de.szut.ita13.rs.wave.main.Game;

public class BasicEnemy extends Entity {

	private Controller controller;
	
	public BasicEnemy(int x, int y, Type type, Controller controller) {
		super(x, y, type);
		this.width = type.getSize();
		this.height = type.getSize();
		this.damage = type.getDamage();
		this.velocityX = 5;
		this.velocityY = 5;
		this.controller = controller;
		this.color = type.getColor();
	}

	@Override
	public void tick() {
		x += velocityX;
		y += velocityY;
		
		if(y <= 0 || y >= Game.HEIGHT - height * 2) velocityY *= -1;
		if(x <= 0 || x >= Game.WIDTH - width) velocityX *= -1;
		
		controller.modificateEntity(new Trail(x, y, Type.Trail, color, width, height, 0.02f, controller), Controller.Modification.ADD);
	}

	@Override
	public void render(Graphics g) {
		g.setColor(color);
		g.fillRect(x, y, width, height);
	}

	@Override
	public Rectangle getBounds() {
		return new Rectangle(x, y, width, height);
	}

}
